#ifndef TEST_PRINT_INFO_H
#define TEST_PRINT_INFO_H

#include "scripting/script_semantic_analyzer.h"
#include "scripting/script_lexer.h"
#include "scripting/script_parser.h"


static void printASTNode(const script::ASTNode &ast_node, const std::string &prefix = "-")
{
    printf("%s %s: %s\n", prefix.c_str(), script::astNodeTypeToString(ast_node.type), ast_node.value.c_str());
    for (const auto &node: ast_node.children)
    {
        printASTNode(node, prefix + "--");
    }
}
static void printASTError(const script::ScriptParser &parser)
{
    script::Token token;
    std::string err_msg;
    parser.getErrorInfo(&token, &err_msg);
    printf("AST error: %d:%d, %s, %s\n", token.line, token.column, token.token_value.c_str(), err_msg.c_str());
}
static void printTokens(const script::Tokens &tokens)
{
    for (const auto &token: tokens.tokens)
    {
        if (token.token_value == "\n")
        {
            printf("%s: \\n, %d:%d\n", script::tokenTypeToString(token.type), token.line, token.column);
        }
        else
        {
            printf("%s: %s, %d:%d\n", script::tokenTypeToString(token.type), token.token_value.c_str(), token.line, token.column);
        }
    }
}

static void printErrorInfo(const script::ScriptLexer &lexer)
{
    int error_line = 0;
    int error_column = 0;
    std::string error_msg;
    lexer.getErrorInfo(&error_line, &error_column, &error_msg);
    printf("error: %d:%d, %s\n", error_line, error_column, error_msg.c_str());
}

#endif //TEST_PRINT_INFO_H
